package com.zfj.Collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @author zfj
 * @date 2022/3/7 -19:17
 */
public class Demo3 {
	public static void main(String[] args) {
		List<Integer> list=new ArrayList<>();
		list.add(20);
		list.add(50);
		list.add(54);
		list.add(28);
		list.add(90);
		System.out.println(list.toString());
		Collections.sort(list);
		System.out.println(list.toString());

		//binarySerarch
		int i = Collections.binarySearch(list, 50);
		System.out.println(i);
		//Copy
		List<Integer> dest=new ArrayList<>();
		for (int i1 = 0; i1 < list.size(); i1++) {
			dest.add(i1);
		}
		Collections.copy(dest,list);
		System.out.println(dest.toString());
		//reverse反转
		Collections.reverse(list);
		System.out.println("反射之后"+list);
		//shuffle打乱
		Collections.shuffle(list);
		System.out.println("打乱后"+list);
		//list转数组
		Integer[] integers = list.toArray(new Integer[10]);
		System.out.println(integers.length);
		System.out.println(Arrays.toString(integers));
		//数组转集合
		String[] name={"张三","李四","王五"};
		List<String> list1=Arrays.asList(name);
		System.out.println(list1);

	}
}
